﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevFx.FrameWork;

namespace DevFx.Web.Controls.Common
{
    public partial class Pager : System.Web.UI.UserControl
    {
        public delegate void PageChange(int pageIndex);
        public event PageChange PageChangeEvent;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.AspNetPager1.AlwaysShow = true;
            }
        }
        public void BindData(PagerCondition pager )
        {
            this.AspNetPager1.PageSize = pager.PageSize;
            this.AspNetPager1.RecordCount = pager.RecordCount;
            this.AspNetPager1.CurrentPageIndex = pager.CurrentPage;
        }
        public void GetData(PagerCondition pager)
        {
            pager.CurrentPage=  this.AspNetPager1.CurrentPageIndex;
        }
        protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            PageChangeEvent( e.NewPageIndex);
        }
    }
}